package com.baizhi.user.controller;


import com.baizhi.user.entity.User;
import com.baizhi.user.service.IUserService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author zhenggang
 * @since 2022-03-15
 */
@RestController
@RequestMapping("/user")
public class UserController {
    @Autowired
    private IUserService us;
    @GetMapping("/login")
    public Map<String,Object> login(String name,String pwd){
        QueryWrapper<User> wrapper = new QueryWrapper<User>();
        wrapper.eq("name",name).eq("pwd",pwd);
        User user = us.getOne(wrapper);
        Map<String,Object> resultMap=new HashMap<>();
        if(user!=null){
            resultMap.put("code",1);
        }else{
            resultMap.put("code",0);
        }
        return resultMap;
    }
}

